Full source code website bán hàng thương mại điện tử gần giống shopee
468.927 lượt xem;
1 <?
2 if (isset($_POST['butSaveLoai'])) {
3 $name=$_POST['name'];
4 $thutu=$_POST['thutu'];
5 $parent=$_POST['parent'];
6 $status=($_POST['chkShow']!=''?1:0);
7
8 $name = trim($_POST['name']);
9 if ($name=="")
10 {
11 echo "<p align=center class='err'>Bạn chưa nhập tên danh mục</p>";
12 }
13 else
14 {
15 if (!empty($_POST['oldid'])) {
16 $oldid = $_POST['oldid'];
17 $sql = "update news_cat set name='".$name."', parent='".$parent."', thutu='".$thutu."', status='".$status."' where id='".$oldid."'";
18 }
19 else
20 $sql = "insert into news_cat (name,parent,status,thutu,date) values ('".$name."','".$parent."','".$status."','".$thutu."',SYSDATE())";
21 if (mysql_query($sql,$con)) {
22 echo "<p align=center class='err'>Đã cập nhật thành công</p><br>";
23 echo "<script>window.location='index.php?act=news_category&page=".$_REQUEST['page']."&code=1'</script>";
24 }
25 else echo "<p align=center class='err'>Không thể cập nhật</p>";
26
27 }
28 }
29 ?>
30
31 <?
32 if (isset($_GET['id'])) {
33 $oldid=$_GET['id'];
34 $sql = "select * from news_cat where id='".$oldid."'";
35 if ($result = mysql_query($sql,$con)) {
36 $row=mysql_fetch_array($result);
37 $name=$row['name'];
38 $parent=$row['parent'];
39 $sortorder=$row['thutu'];
40 }
41 }
42 ?>
43 <script language="Javascript1.2"><!-- // load htmlarea
44 _editor_url = "htmlarea/"; // URL to htmlarea files
45 var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
46 if (navigator.userAgent.indexOf('Mac') >= 0) { win_ie_ver = 0; }
47 if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
48 if (navigator.userAgent.indexOf('Opera') >= 0) { win_ie_ver = 0; }
49 if (win_ie_ver >= 5.5) {
50 document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
51 document.write(' language="Javascript1.2"></scr' + 'ipt>');
52 } else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
53 // --></script>
54
55 <form method="POST" action="index.php?">
56 <input type=hidden name="act" value="news_category_m">
57 <input type=hidden name="oldid" value="<? echo $oldid; ?>">
58 <input type=hidden name="page" value="<? echo $_REQUEST['page']; ?>">
59 <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#0069A8" width="100%" id="AutoNumber1">
60 <tr>
61 <td width="45%" height="20" class="title" align="center">Thêm mới / Cập nhật
62 : Danh mục tin tuc</td>
63 </tr>
64 <tr>
65 <td width="45%">
66 <table border="0" cellpadding="4" bordercolor="#111111" width="124%" id="AutoNumber2" cellspacing="0">
67 <tr>
68 <td width="15%" class="smallfont">
69 <p align="right">Tên danh mục</td>
70 <td width="1%" class="smallfont">
71 <font color="#FF0000">*</font></td>
72 <td width="83%" class="smallfont">
73 <INPUT value="<? echo $name; ?>" TYPE="text" NAME="name" CLASS=textbox size="34"></td>
74 </tr>
75 <tr>
76 <td width="15%" class="smallfont" align="right">
77 Không hiển thị</td>
78 <td width="1%" class="smallfont" align="right">
79 </td>
80 <td width="83%" class="smallfont">
81 <input type="checkbox" name="chkShow" value="ON" <? if ($status>0) echo 'checked' ?>></td>
82 </tr>
83 <tr>
84 <td width="15%" class="smallfont" align="right">
85 Thuộc danh mục</td>
86 <td width="1%" class="smallfont" align="center">
87 </td>
88 <td width="83%" class="smallfont">
89 <select size="1" name="parent" >
90 <option value="0">Danh mục gốc</option>
91 <?
92 $cats=GetListCatNews_admin(0);
93 foreach ($cats as $cat)
94 {
95 if ($cat[0]==$parent)
96 echo "<option value=".$cat[0]." selected>".$cat[1]."</option>";
97 else
98 echo "<option value=".$cat[0].">".$cat[1]."</option>";
99 }
100 ?>
101 </select>
102 </td>
103 </tr>
104
105 <td width="15%" class="smallfont" align="right" valign="top">
106 Thứ tự sắp xếp</td>
107 <td width="1%" class="smallfont">
108 </td>
109 <td width="83%" class="smallfont">
110 <INPUT value="<? echo $thutu; ?>" TYPE="text" NAME="thutu" CLASS=textbox size="4"></td>
111 </tr>
112 <tr>
113 <td width="15%" class="smallfont">
114 <p align="right">
115 <INPUT TYPE="submit" NAME="butSaveLoai" VALUE="Cập nhật" CLASS=button> </td>
116 <td width="1%" class="smallfont">
117 </td>
118 <td width="83%" class="smallfont"><p align="left"> <INPUT TYPE="reset" CLASS=button value="Nhập lại"></td>
119 </tr>
120
121 </table>
122 </td>
123 </tr>
124 </table>
125 </form>
2 if (isset($_POST['butSaveLoai'])) {
3 $name=$_POST['name'];
4 $thutu=$_POST['thutu'];
5 $parent=$_POST['parent'];
6 $status=($_POST['chkShow']!=''?1:0);
7
8 $name = trim($_POST['name']);
9 if ($name=="")
10 {
11 echo "<p align=center class='err'>Bạn chưa nhập tên danh mục</p>";
12 }
13 else
14 {
15 if (!empty($_POST['oldid'])) {
16 $oldid = $_POST['oldid'];
17 $sql = "update news_cat set name='".$name."', parent='".$parent."', thutu='".$thutu."', status='".$status."' where id='".$oldid."'";
18 }
19 else
20 $sql = "insert into news_cat (name,parent,status,thutu,date) values ('".$name."','".$parent."','".$status."','".$thutu."',SYSDATE())";
21 if (mysql_query($sql,$con)) {
22 echo "<p align=center class='err'>Đã cập nhật thành công</p><br>";
23 echo "<script>window.location='index.php?act=news_category&page=".$_REQUEST['page']."&code=1'</script>";
24 }
25 else echo "<p align=center class='err'>Không thể cập nhật</p>";
26
27 }
28 }
29 ?>
30
31 <?
32 if (isset($_GET['id'])) {
33 $oldid=$_GET['id'];
34 $sql = "select * from news_cat where id='".$oldid."'";
35 if ($result = mysql_query($sql,$con)) {
36 $row=mysql_fetch_array($result);
37 $name=$row['name'];
38 $parent=$row['parent'];
39 $sortorder=$row['thutu'];
40 }
41 }
42 ?>
43 <script language="Javascript1.2"><!-- // load htmlarea
44 _editor_url = "htmlarea/"; // URL to htmlarea files
45 var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
46 if (navigator.userAgent.indexOf('Mac') >= 0) { win_ie_ver = 0; }
47 if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
48 if (navigator.userAgent.indexOf('Opera') >= 0) { win_ie_ver = 0; }
49 if (win_ie_ver >= 5.5) {
50 document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
51 document.write(' language="Javascript1.2"></scr' + 'ipt>');
52 } else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
53 // --></script>
54
55 <form method="POST" action="index.php?">
56 <input type=hidden name="act" value="news_category_m">
57 <input type=hidden name="oldid" value="<? echo $oldid; ?>">
58 <input type=hidden name="page" value="<? echo $_REQUEST['page']; ?>">
59 <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#0069A8" width="100%" id="AutoNumber1">
60 <tr>
61 <td width="45%" height="20" class="title" align="center">Thêm mới / Cập nhật
62 : Danh mục tin tuc</td>
63 </tr>
64 <tr>
65 <td width="45%">
66 <table border="0" cellpadding="4" bordercolor="#111111" width="124%" id="AutoNumber2" cellspacing="0">
67 <tr>
68 <td width="15%" class="smallfont">
69 <p align="right">Tên danh mục</td>
70 <td width="1%" class="smallfont">
71 <font color="#FF0000">*</font></td>
72 <td width="83%" class="smallfont">
73 <INPUT value="<? echo $name; ?>" TYPE="text" NAME="name" CLASS=textbox size="34"></td>
74 </tr>
75 <tr>
76 <td width="15%" class="smallfont" align="right">
77 Không hiển thị</td>
78 <td width="1%" class="smallfont" align="right">
79 </td>
80 <td width="83%" class="smallfont">
81 <input type="checkbox" name="chkShow" value="ON" <? if ($status>0) echo 'checked' ?>></td>
82 </tr>
83 <tr>
84 <td width="15%" class="smallfont" align="right">
85 Thuộc danh mục</td>
86 <td width="1%" class="smallfont" align="center">
87 </td>
88 <td width="83%" class="smallfont">
89 <select size="1" name="parent" >
90 <option value="0">Danh mục gốc</option>
91 <?
92 $cats=GetListCatNews_admin(0);
93 foreach ($cats as $cat)
94 {
95 if ($cat[0]==$parent)
96 echo "<option value=".$cat[0]." selected>".$cat[1]."</option>";
97 else
98 echo "<option value=".$cat[0].">".$cat[1]."</option>";
99 }
100 ?>
101 </select>
102 </td>
103 </tr>
104
105 <td width="15%" class="smallfont" align="right" valign="top">
106 Thứ tự sắp xếp</td>
107 <td width="1%" class="smallfont">
108 </td>
109 <td width="83%" class="smallfont">
110 <INPUT value="<? echo $thutu; ?>" TYPE="text" NAME="thutu" CLASS=textbox size="4"></td>
111 </tr>
112 <tr>
113 <td width="15%" class="smallfont">
114 <p align="right">
115 <INPUT TYPE="submit" NAME="butSaveLoai" VALUE="Cập nhật" CLASS=button> </td>
116 <td width="1%" class="smallfont">
117 </td>
118 <td width="83%" class="smallfont"><p align="left"> <INPUT TYPE="reset" CLASS=button value="Nhập lại"></td>
119 </tr>
120
121 </table>
122 </td>
123 </tr>
124 </table>
125 </form>